<?php



function neoobject_admin_itemprop_main(){
include_once XOOPS_ROOT_PATH."/class/template.php";
$itempropH = & xoops_getmodulehandler('itemprop');
$propcatH = & xoops_getmodulehandler('itempropcat','neoobject');
$proptypeH = & xoops_getmodulehandler('itemproptype','neoobject');


$XoopsTpl = new XoopsTpl();
xoops_cp_header();
	echo $XoopsTpl->fetch('db:neoobject_admin_mainmenu.html');
	$propcatarr = $propcatH->getObjects();
	foreach ($propcatarr as $propcatO){

		$propcatO->proparr = $proparr = $itempropH->getObjects(new Criteria('propcat',$propcatO->getVar('id')));

	$XoopsTpl->append('propcatarr',$propcatO);	
	}
	
	echo $XoopsTpl->fetch('db:neoobject_admin_itemprop_main.html');
#	include XOOPS_ROOT_PATH."/modules/neoobject/include/neoobjectprop_admin_cat_addform.inc.php";
 	echo $XoopsTpl->fetch("db:neoobject_admin_itempropcat_create.html");
    if ($propcatH->getCount()) {
		#$propcatarr = $propcatH->getObjects();	
		$itempropO = $itempropH->create();
		$itempropO->categories = $propcatarr;
		$itempropO->types = $proptypeH->getObjects();
#print_r($itempropO->types);
		$XoopsTpl->assign_by_ref('itempropO',$itempropO);

 	echo $XoopsTpl->fetch("db:neoobject_admin_itemprop_create.html");
	#	include XOOPS_ROOT_PATH."/modules/neoobject/include/neoobjectprop_admin_addform.inc.php";	
    }	
xoops_cp_footer();
}
function neoobject_admin_itemprop_create_ok(){
$itempropH = & xoops_getmodulehandler('itemprop','neoobject');	
	#print_r($propcatH);
	$itempropO = & $itempropH->create();
	$itempropO->setFormVars($_POST,'itemprop_');	
	#print_R($propcatO);
	$itempropH->insert($itempropO);

	 $_SESSION['neoobject']['itemprop']['propcat'] = $itempropO->getVar('propcat');
 	 $_SESSION['neoobject']['itemprop']['typevalue'] = $itempropO->getVar('typevalue');
	redirect_header("index.php?type=itemprop");

}
function neoobject_admin_itemprop_edit(){
include_once XOOPS_ROOT_PATH."/class/template.php";
$itempropH = & xoops_getmodulehandler('itemprop','neoobject');
$propcatH = & xoops_getmodulehandler('itempropcat','neoobject');
$proptypeH = & xoops_getmodulehandler('itemproptype','neoobject');


$XoopsTpl = new XoopsTpl();
xoops_cp_header();
	echo $XoopsTpl->fetch('db:neoobject_admin_mainmenu.html');
		$itempropO = $itempropH->get($_GET['id']);
		$itempropO->categories = $propcatH->getObjects();
		$itempropO->types = $proptypeH->getObjects();
		$XoopsTpl->assign_by_ref('itempropO',$itempropO);

	 	echo $XoopsTpl->fetch("db:neoobject_admin_itemprop_edit.html");
	#	include XOOPS_ROOT_PATH."/modules/neoobject/include/neoobjectprop_admin_addform.inc.php";	

xoops_cp_footer();
}
function neoobject_admin_itemprop_edit_ok(){
	$itempropH = & xoops_getmodulehandler('itemprop','neoobject');	
	#print_r($propcatH);
	$itempropO = & $itempropH->get($_GET['id']);
	$itempropO->setFormVars($_POST,'itemprop_');	
	#print_R($propcatO);
	$itempropH->insert($itempropO);
	redirect_header("index.php?type=itemprop");

}
function neoobject_admin_itemprop_delete_ok(){

	$itempropH = & xoops_getmodulehandler('itemprop','neoobject');		
	
	$itempropO = & $itempropH->get($_GET['id']);
	
	$itempropH->delete($itempropO);
	
	
	redirect_header("index.php?type=itemprop");
}

function neoobject_admin_itemprop_cat_create_ok(){
	$itempropcatH = & xoops_getmodulehandler('itempropcat','neoobject');	
	#print_r($propcatH);
	$itempropcatO = & $itempropcatH->create();
	$itempropcatO->setFormVars($_POST,'itempropcat_');	
	#print_R($propcatO);
	$itempropcatH->insert($itempropcatO);
	 $_SESSION['neoobject']['itemprop']['propcat'] = $itempropcatO->getVar('id');
	redirect_header("index.php?type=itemprop");
}

function neoobject_admin_itemprop_cat_edit(){
include_once XOOPS_ROOT_PATH."/class/template.php";

$itempropcatH = & xoops_getmodulehandler('itempropcat','neoobject');

$XoopsTpl = new XoopsTpl();
xoops_cp_header();
	echo $XoopsTpl->fetch('db:neoobject_admin_mainmenu.html');
		$itempropcatO = $itempropcatH->get($_GET['id']);
		$XoopsTpl->assign_by_ref('itempropcatO',$itempropcatO);

	 	echo $XoopsTpl->fetch("db:neoobject_admin_itempropcat_edit.html");
	#	include XOOPS_ROOT_PATH."/modules/neoobject/include/neoobjectprop_admin_addform.inc.php";	

xoops_cp_footer();
}
function neoobject_admin_itemprop_cat_edit_ok(){
	$itempropcatH = & xoops_getmodulehandler('itempropcat','neoobject');	
	#print_r($propcatH);
	$itempropcatO = & $itempropcatH->get($_GET['id']);
	$itempropcatO->setFormVars($_POST,'itempropcat_');	
	#print_R($propcatO);
	$itempropcatH->insert($itempropcatO);
	redirect_header("index.php?type=itemprop");
}
function neoobject_admin_itemprop_cat_delete_ok(){
	$itempropcatH = & xoops_getmodulehandler('itempropcat','neoobject');	
	$itempropH = & xoops_getmodulehandler('itemprop','neoobject');		
	
	$itempropcatO = & $itempropcatH->get($_GET['id']);
	$properties = $itempropH->getObjects(new Criteria('propcat',$itempropcatO->getVar("id")));
	
	foreach ($properties as $itempropO){
	 $itempropH->delete($itempropO);
	}
	$itempropcatH->delete($itempropcatO);
	
	
	redirect_header("index.php?type=itemprop");
}

?>